package neuron.library.ga.replication;

import java.util.Random;

import neuron.library.ga.AbstractGeneticMachine;
import neuron.library.ga.common.AbstractChromosome;
import neuron.library.ga.common.Population;

/*
 * Replicates 5% of elite chromosomes.
 */
public class RandomLowRateReplication extends ReplicationStrategy {

	public RandomLowRateReplication(AbstractGeneticMachine gm) {
		super(gm);
	}

	@Override
	public void replication(Population population) {
		Random rand = new Random();
		
		if (rand.nextInt(1000)%1000 == 0) {
			int size = gm.getConfig().getPopulatonSize();
			population.add(population.get(rand.nextInt(size)));
		}
		
	}

}
